package com.egghiro.j2se.game.sace.model.actor.bullet.bulletshooter;

import com.egghiro.framework.j2se.game.core.model.actor.IActor2D;
import com.egghiro.j2se.game.sace.device.factory.bulletfactory.BulletFactory;
import com.egghiro.j2se.game.sace.model.actor.BulletCluster;

/**
 * 以一定的时间间隔发射速度递增的子弹
 * @project SACE
 * @designPattern 
 * @characterInPattern
 * @version 0.1
 */
public class AutoTimerSpeedUpBulletShooter extends AutoBulletShooter{
    private static final double DEFAULT_SPEED = 10;
    private static final double SPEED_UP = 5;
    private double speed = DEFAULT_SPEED;
    
    /**
     * 
     * @param shiftX
     * @param shiftY
     * @param coverAngle
     * @param stepAngle
     * @param canvasBulletCluster
     * @param factory
     * @param interval
     * @param ammunition
     */
    public AutoTimerSpeedUpBulletShooter(int shiftX,int shiftY,int coverAngle,int stepAngle,BulletCluster canvasBulletCluster,BulletFactory factory,int interval,int ammunition){
        this(shiftX,shiftY,coverAngle,stepAngle,canvasBulletCluster, factory, interval, ammunition,0);
    }

    /**
     * 
     * @param shiftX
     * @param shiftY
     * @param coverAngle
     * @param stepAngle
     * @param canvasBulletCluster
     * @param factory
     * @param interval
     * @param ammunition
     * @param delay
     */
    public AutoTimerSpeedUpBulletShooter(int shiftX,int shiftY,int coverAngle,int stepAngle,BulletCluster canvasBulletCluster,BulletFactory factory,int interval,int ammunition,long delay){
        super(shiftX,shiftY,coverAngle,stepAngle,canvasBulletCluster, factory, interval, ammunition,delay);
    }
    
    @Override
    protected void fire(int flyerX, int flyerY, IActor2D target, int axisAngle) {
//        this.canvasBulletCluster.add(this.factory.createFlyer(flyerX + super.shiftX, flyerY + super.shiftY,axisAngle - super.shiftAngle,super.coverAngle , stepAngle, target));
        this.canvasBulletCluster.add(this.factory.createFlyer(flyerX + super.shiftX, flyerY + super.shiftY,speed,axisAngle - super.shiftAngle,super.coverAngle , stepAngle, target));
        speed +=SPEED_UP;// 速度递增
        super.ammunition--;
    }

    @Override
    public void reload(){
       super.reload();
       speed = DEFAULT_SPEED;
    }

}
